
<template>
    <div class="mui-numbox" data-numbox-min='1'>
    <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
    <!-- 监听文本框的change事件，来动态获取选择到的数量 -->
    <input id="test" class="mui-input-numbox" type="number" :value="initcount" ref="nobox" @change="countChanged" />
    <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
</div>
</template>

<script>
import {mapMutations} from "vuex"
import mui from "../../../lib/mui/js/mui.js"
export default{
    data(){
        return{}
    },
    mounted(){
       
    },
    methods:{
        ...mapMutations(["updateGoodsCount"]),
        countChanged(){
            //获取商品数量
            const val = parseInt(this.$refs.nobox.value);
            //更新数量
            this.updateGoodsCount({id:this.id,count:val});
        }
    },
    props:["initcount","id"]
   
}
</script>

<style scoped>

</style>
